<template>
	<view class="my-app">
		<view class="my-top">
			<view class="top-head">
				<image :src=avatarUrl></image>
				<text>{{nickName}}</text>
			</view>
			<view class="out" @click="clickLogin" v-if="avatarUrl == ''">请登录</view>
			<view class="out" @click="clickLogin" v-else>退出登录</view>


		</view>

		<view class="four">
			<view class="four-item">
				<image src="../../static/zixun.png" mode=""></image>
				<text>我的咨询</text>
			</view>
			<view class="four-item">
				<image src="../../static/ziliao.png" mode=""></image>
				<text>我的资料</text>
			</view>
			<view class="four-item">
				<image src="../../static/loupan.png" mode=""></image>
				<text>关注楼盘</text>
			</view>
			<view class="four-item">
				<image src="../../static/xiaoxi.png" mode=""></image>
				<text>消息通知</text>
			</view>
		</view>

		<view class="my-content">
			<view class="content-one">
				<view class="item" v-for="item in menus" :key="item.text" v-if="item.text">
					<image :src="'../../static'+ item.img" mode=""></image>
					<view class="item-text">
						<text>{{item.text}}</text>
						<text> > </text>
					</view>
				</view>
				<view v-else style="width: 100%;height: 20px;">
					
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				nickName: '',
				avatarUrl: '',
				menus: [{
						text: '我的积分',
						img: '/jifen.png'
					},
					{
						text: '我的订阅',
						img: '/dingyue.png'
					},
					{
						text: '房贷计算器',
						img: '/jisuanqi.png'
					},
					{},
					{
						text: '浏览记录',
						img: '/liulanjilu.png'
					},
					{
						text: '微聊客服',
						img: '/weiliao.png'
					},
					{},
					{
						text: '我的问答',
						img: '/wenda.png'
					},
					{
						text: '设置',
						img: '/shezhi.png'
					},
				]
			};
		},
		methods: {
			clickLogin() {
				uni.getUserProfile({
					desc: '获取您的信息,登录',
					success: (res) => {
						this.nickName = res.userInfo.nickName
						this.avatarUrl = res.userInfo.avatarUrl
						console.log(this.nickName);
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		height: 100%;
	}

	.my-app {
		height: 100%;
		background-color: #f4f3f8;
		position: relative;
		width: 100%;

		.my-top {
			display: flex;
			justify-content: space-between;
			background-color: #41a863;
			height: 100px;
			align-items: center;
			color: #fff;
			padding: 5px 10px 30px 15px;

			.top-head {
				display: flex;
				align-items: center;

				image {
					width: 55px;
					height: 56px;
					border-radius: 50%;
					border: 1px solid #fff;
					margin-right: 20px;
				}
			}

			.out {
				padding: 7px 15px;
				border: 1px solid #fff;
				border-radius: 30px;
				font-size: 14px;
			}

		}

		.four {
			display: flex;
			justify-content: space-around;
			position: absolute;
			height: 70px;
			width: 90%;
			left: 0;
			right: 0;
			top: 110px;
			margin: auto;
			background-color: #fff;
			border-radius: 10px;
			align-items: center;

			.four-item {
				display: flex;
				flex-direction: column;
				align-items: center;
				width: 25%;
				font-size: 12px;

				image {
					width: 25px;
					height: 25px;
					margin-bottom: 5px;
				}
			}
		}

		.my-content {
			margin-top: 65px;
			padding: 0 10px;
			width: 100%;
			box-sizing: border-box;

			.content-one {
				.item {
					background-color: #fff;
					display: flex;
					width: 100%;
					align-items: center;
					border-bottom: 1px solid #e7e7e7;
					box-sizing: border-box;
					padding: 10px;

					image {
						width: 20px;
						height: 20px;
						margin-right: 15px;
					}

					.item-text {
						flex: 1;
						display: flex;
						align-items: center;
						justify-content: space-between;

					}
				}
			}
		}
	}
</style>
